home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / sharkatt.c < prev    next >
C/C++ Source or Header  |  2000-04-23  |  7KB  |  237 lines

  1. /***************************************************************************
  2.  
  3.  Shark Attack
  4.  
  5.  driver by Victor Trucco, Mike Balfour
  6.  
  7.  TODO:
  8.   - Finish 8255 emulation and separate into new source file.
  9.   - Add support for audio cassette for diver sounds (port C of 8255)
  10.   - Verify that nothing needs to be done for the TMS9927 VTAC.
  11.   - Locate the "cocktail" set of ROMs.
  12.   - Figure out what the write to port 0 is used for.
  13.  
  14.  ***************************************************************************/
  15.  
  16. #include "driver.h"
  17. #include "vidhrdw/generic.h"
  18.  
  19. extern void sharkatt_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  20.  
  21. WRITE_HANDLER( sharkatt_videoram_w );
  22. WRITE_HANDLER( sharkatt_color_map_w );
  23. WRITE_HANDLER( sharkatt_color_plane_w );
  24. WRITE_HANDLER( sharkatt_vtcsel_w );
  25.  
  26. static int PA_8255 = 0;
  27. static int PB_8255 = 0;
  28. static int PC_8255 = 0;
  29.  
  30. static READ_HANDLER( sharkatt_8255_r )
  31. {
  32.     switch (offset & 0x03)
  33.     {
  34.         case 1:
  35.             /* SWITCH BANK 1 - B6 */
  36.             if (PA_8255 & 0x01)
  37.                 return input_port_0_r(offset);
  38.             /* SWITCH BANK 0 - B5 */
  39.             if (PA_8255 & 0x02)
  40.                 return input_port_1_r(offset);
  41.             /* PFPCONN - B8 */
  42.             if (PA_8255 & 0x04)
  43.                 return input_port_2_r(offset);
  44.             /* PFDCONN - B7 */
  45.             if (PA_8255 & 0x08)
  46.                 return input_port_3_r(offset);
  47.  
  48.             logerror("8255: read from port B, PA = %X\n",PA_8255);
  49.             break;
  50.         default:
  51.             logerror("8255: read from port<>B, offset %d\n",offset);
  52.             break;
  53.     }
  54.  
  55.     return 0;
  56. }
  57.  
  58. static WRITE_HANDLER( sharkatt_8255_w )
  59. {
  60.     switch (offset & 0x03)
  61.     {
  62.         case 0:        PA_8255 = data;    break;
  63.         case 1:        PB_8255 = data;    break;
  64.         case 2:        PC_8255 = data;    break;
  65.         case 3:        logerror("8255 Control = %02X\n",data);
  66.     }
  67. }
  68.  
  69. static struct MemoryReadAddress readmem[] =
  70. {
  71.     { 0x0000, 0x7fff, MRA_ROM },    /* ROMSEL - ROMs at 6800-7fff are unpopulated */
  72.     { 0x8000, 0x9fff, MRA_RAM },    /* RAMSEL */
  73.     { 0xc000, 0xdfff, MRA_RAM },
  74.     { -1 }  /* end of table */
  75. };
  76.  
  77. static struct MemoryWriteAddress writemem[] =
  78. {
  79.     { 0x0000, 0x7fff, MWA_ROM },    /* ROMSEL - ROMs at 6800-7fff are unpopulated */
  80.     { 0x8000, 0x9fff, MWA_RAM },    /* RAMSEL */
  81.     { 0xc000, 0xdfff, sharkatt_videoram_w, &videoram, &videoram_size },
  82.     { -1 }  /* end of table */
  83. };
  84.  
  85.  
  86. static struct IOReadPort readport[] =
  87. {
  88.     { 0x30, 0x3f, sharkatt_8255_r },
  89.     { 0x41, 0x41, AY8910_read_port_0_r },
  90.     { 0x43, 0x43, AY8910_read_port_1_r },
  91.     { -1 }  /* end of table */
  92. };
  93.  
  94. /* TODO: figure out what this does!!! */
  95. static WRITE_HANDLER( fake_w )
  96. {
  97. }
  98.  
  99. static struct IOWritePort writeport[] =
  100. {
  101.     { 0x00, 0x00, fake_w },
  102.     { 0x30, 0x3f, sharkatt_8255_w },
  103.     { 0x40, 0x40, AY8910_control_port_0_w },
  104.     { 0x41, 0x41, AY8910_write_port_0_w },
  105.     { 0x42, 0x42, AY8910_control_port_1_w },
  106.     { 0x43, 0x43, AY8910_write_port_1_w },
  107.     { 0x50, 0x5f, sharkatt_color_plane_w },
  108.     { 0x60, 0x6f, sharkatt_vtcsel_w },
  109.     { 0x70, 0x7f, sharkatt_color_map_w },
  110.     { -1 }  /* end of table */
  111. };
  112.  
  113. INPUT_PORTS_START( sharkatt )
  114.  
  115.     PORT_START      /* IN0 */
  116.     PORT_DIPNAME( 0x01, 0x01, DEF_STR( Coinage ) )
  117.     PORT_DIPSETTING(    0x00, DEF_STR( 2C_1C ) )
  118.     PORT_DIPSETTING(    0x01, DEF_STR( 1C_1C ) )
  119.     PORT_BIT( 0xFE, IP_ACTIVE_HIGH, IPT_UNKNOWN )  // Unlabelled DIPs
  120.  
  121.     PORT_START      /* IN1 */
  122.     PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )
  123.     PORT_DIPSETTING(    0x00, "3" )
  124.     PORT_DIPSETTING(    0x01, "4" )
  125.     PORT_DIPSETTING(    0x02, "5" )
  126.     PORT_DIPSETTING(    0x03, "5" )
  127.     PORT_BIT( 0x7C, IP_ACTIVE_HIGH, IPT_UNKNOWN )  // Unlabelled DIPs
  128.     PORT_BITX(0x80, IP_ACTIVE_HIGH, IPT_SERVICE | IPF_TOGGLE, "Self Test", KEYCODE_F2, IP_JOY_NONE )
  129.  
  130.     PORT_START      /* IN2 */
  131.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY )
  132.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY )
  133.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY )
  134.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
  135.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START1 )
  136.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 )
  137.     PORT_BITX(0x40, IP_ACTIVE_LOW, IPT_BUTTON1, "Munch",  IP_KEY_DEFAULT, IP_JOY_DEFAULT )
  138.     PORT_BITX(0x80, IP_ACTIVE_LOW, IPT_BUTTON2, "Thrust", IP_KEY_DEFAULT, IP_JOY_DEFAULT )
  139.  
  140.     PORT_START      /* IN3 */
  141.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_COCKTAIL)
  142.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_COCKTAIL)
  143.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_COCKTAIL)
  144.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_COCKTAIL)
  145.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_TILT )
  146.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 )
  147.     PORT_BITX(0x40, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL, "Munch",  IP_KEY_DEFAULT, IP_JOY_DEFAULT )
  148.     PORT_BITX(0x80, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_COCKTAIL, "Thrust", IP_KEY_DEFAULT, IP_JOY_DEFAULT )
  149.  
  150. INPUT_PORTS_END
  151.  
  152. static struct AY8910interface ay8910_interface =
  153. {
  154.     2,    /* 2 chips */
  155.     4000000/4,    /* Z80 Clock / 4 */
  156.     { 25, 25 },
  157.     { 0 },
  158.     { 0 },
  159.     { 0 },
  160.     { 0 }
  161. };
  162.  
  163. static int sharkatt_interrupt(void)
  164. {
  165.     /* SLAM switch causes an NMI if it's pressed */
  166.     if ((input_port_3_r(0) & 0x10) == 0)
  167.         return nmi_interrupt();
  168.  
  169.     return interrupt();
  170. }
  171.  
  172. static struct MachineDriver machine_driver_sharkatt =
  173. {
  174.     /* basic machine hardware */
  175.     {
  176.         {
  177.             CPU_Z80,
  178.             4000000,        /* 4 Mhz? */
  179.             readmem,writemem,readport,writeport,
  180.             sharkatt_interrupt,1
  181.         }
  182.     },
  183.     60, DEFAULT_60HZ_VBLANK_DURATION,       /* frames per second, vblank duration */
  184.     1,      /* single CPU, no need for interleaving */
  185.     0,
  186.  
  187.     /* video hardware */
  188.     32*8, 32*8, { 0*8, 32*8-1, 2*8, 30*8-1 },
  189.     0,      /* no gfxdecodeinfo - bitmapped display */
  190.     16, 16,
  191.     0,
  192.  
  193.     VIDEO_TYPE_RASTER | VIDEO_SUPPORTS_DIRTY | VIDEO_MODIFIES_PALETTE,
  194.     0,
  195.     generic_vh_start,
  196.     generic_vh_stop,
  197.     sharkatt_vh_screenrefresh,
  198.  
  199.     /* sound hardware */
  200.     0,0,0,0,
  201.     {
  202.         {
  203.             SOUND_AY8910,
  204.             &ay8910_interface
  205.         }
  206.     }
  207. };
  208.  
  209.  
  210.  
  211. /***************************************************************************
  212.  
  213.   Game driver(s)
  214.  
  215. ***************************************************************************/
  216.  
  217. ROM_START( sharkatt )
  218.     ROM_REGION( 0x10000, REGION_CPU1 )     /* 64k for code */
  219.     ROM_LOAD( "sharkatt.0",   0x0000, 0x0800, 0xc71505e9 )
  220.     ROM_LOAD( "sharkatt.1",   0x0800, 0x0800, 0x3e3abf70 )
  221.     ROM_LOAD( "sharkatt.2",   0x1000, 0x0800, 0x96ded944 )
  222.     ROM_LOAD( "sharkatt.3",   0x1800, 0x0800, 0x007283ae )
  223.     ROM_LOAD( "sharkatt.4a",  0x2000, 0x0800, 0x5cb114a7 )
  224.     ROM_LOAD( "sharkatt.5",   0x2800, 0x0800, 0x1d88aaad )
  225.     ROM_LOAD( "sharkatt.6",   0x3000, 0x0800, 0xc164bad4 )
  226.     ROM_LOAD( "sharkatt.7",   0x3800, 0x0800, 0xd78c4b8b )
  227.     ROM_LOAD( "sharkatt.8",   0x4000, 0x0800, 0x5958476a )
  228.     ROM_LOAD( "sharkatt.9",   0x4800, 0x0800, 0x4915eb37 )
  229.     ROM_LOAD( "sharkatt.10",  0x5000, 0x0800, 0x9d07cb68 )
  230.     ROM_LOAD( "sharkatt.11",  0x5800, 0x0800, 0x21edc962 )
  231.     ROM_LOAD( "sharkatt.12a", 0x6000, 0x0800, 0x5dd8785a )
  232. ROM_END
  233.  
  234.  
  235.  
  236. GAME( 1980, sharkatt, 0, sharkatt, sharkatt, 0, ORIENTATION_SWAP_XY, "Pacific Novelty", "Shark Attack" )
  237.